package com.ita.pojo;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.junit.experimental.theories.Theories;

/**
 * 
 * @author WENGTO2
 *
 */
@Entity
@Table(name="c_order")
@GenericGenerator(name="uu", strategy="uuid")
//@GeneratedValue(generator="uu")
public class Order {
	@Id
	@GeneratedValue(generator="uu")
	private String id;
	@OneToOne
	@JoinColumn(name="m_id")
	private MUser merchant;
	@OneToOne
	@JoinColumn(name="c_id")
	private User cUser;
	
	@Column(name="address")
	private String c_address;
	
	private double total; //memory
	
	private int state;
	private long create_time;
	@OneToMany(mappedBy="order", fetch=FetchType.EAGER, cascade= {CascadeType.PERSIST, CascadeType.REMOVE})
	private Set<OrderItem> orderItemSet = new HashSet<OrderItem>();
	
	public Set<OrderItem> getOrderItemSet() {
		return orderItemSet;
	}
	public void setOrderItemSet(Set<OrderItem> orderItemSet) {
		this.orderItemSet = orderItemSet;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	public MUser getMerchant() {
		return merchant;
	}
	public void setMerchant(MUser merchant) {
		this.merchant = merchant;
	}
	
	public User getcUser() {
		return cUser;
	}
	public void setcUser(User cUser) {
		this.cUser = cUser;
	}
	public double getTotal() {
		return total;
	}
	public void setTotal(double total) {
		this.total = total;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	public long getCreate_time() {
		return create_time;
	}
	public void setCreate_time(long create_time) {
		this.create_time = create_time;
	}
	
	
	public Order(String id, MUser merchant, User cUser, double total, int state, long create_time,String c_address) {
		super();
		this.id = id;
		this.merchant = merchant;
		this.cUser = cUser;
		this.total = total;
		this.state = state;
		this.create_time = create_time;
		this.setC_address(c_address);
	}
	@Override
	public String toString() {
		return "Order [id=" + id + ", merchant=" + merchant + ", cUser=" + cUser + ", total=" + total + ", state=" + state
				+ ", create_time=" + create_time + "]";
	}
	public Order() {
		super();
		// TODO Auto-generated constructor stub
	}
	public String getC_address() {
		return c_address;
	}
	public void setC_address(String c_address) {
		this.c_address = c_address;
	}
	
	
	
	
	
}
